/*****目标团队--靶标 --综合演练*****/
<template><!---->
    <search-table
	    ref="searchTable"
		:columns="targetTeamCol"
        :data="targetTeamData"
		:total="targetTeamTotal"
		:page.sync="queryTargetTeamInfo.pageIndex"
		:size.sync="queryTargetTeamInfo.pageSize"
		@change-size="getTargetSize"
		@change-page="getTargetPage"
	>
    <template slot="search">
            <Button type='primary' ghost @click="showAddAndUpdate('')" :disabled="disabledAllBtn">
                <Icon type="ios-add" :size="16"/>
                添加任务
            </Button>
            <Select filterable v-model="queryTargetTeamInfo.isNeedSubmitFlag" placeholder="验证方式" @on-change="getTargetPage(1)"
                    style="width:150px;margin-left:15px;" transfer clearable>
                <Option :value=0>报告</Option>
                <Option :value=1>Flag</Option>
                <Option :value=2>Checker</Option>
            </Select>
            <Select filterable v-model="queryTargetTeamInfo.type" placeholder="任务类型" @on-change="getTargetPage(1)"
                    style="width:150px;margin-left:15px;" transfer clearable>
                <Option :value=1>虚拟机靶标</Option>
                <Option :value=0>实物靶标</Option>
                <Option :value=2>分析靶标</Option>
            </Select>
            <Select filterable v-model="queryTargetTeamInfo.name" placeholder="请选择任务" @on-change="getTargetPage(1)"
                    style="width:150px;margin-left:15px;" transfer clearable>
                <Option v-for="item in allTargetTeamData" :value="item.name" :key="item.id" :title="item.name">{{ item.name }}</Option>
            </Select>
            <Select filterable v-model="queryTargetTeamInfo.isExistTips" placeholder="是否包含附件" @on-change="getTargetPage(1)"
                    style="width:150px;margin-left:15px;" transfer clearable>
                <Option value="0">无附件</Option>
                <Option value="1">有附件</Option>
            </Select>
            <!--<DatePicker format="yyyy-MM-dd HH:mm:ss" type="daterange"  placeholder="选择日期" style="width: 200px"
                        @on-change="searchTargetPrjD"></DatePicker>-->
            <!--<Input v-model.trim="searchPrjString" search placeholder="任务显示名称" style="width: 200px" @on-search="searchTargetPrj"  />-->
            <!-- <Page :total=targetTeamTotal
                  show-total show-elevator @on-page-size-change="getTargetSize"
                  :current="queryTargetTeamInfo.pageIndex"
                  @on-change="getTargetPage" style="float: right">
            </Page> -->
    </template>
    <Modal v-model="targetModal.show"
                   :title="targetModal.title"
                   :loading="targetModal.loading"
                   width="600px"
                   :mask-closable="false"
                   @on-cancel="handleReset('formValidate')"
                   @on-ok="saveTargetTeam">
                <Form ref="formValidate" :model="formValidate" :rules="ruleValidate" :label-width="100">
                    <Alert type="warning" show-icon v-if="targetModal.type == 2">
                        <p style="color:#f90">修改任务的注意事项：</p>
                        <p>1.如果是静态Flag任务，需要根据当前使用的环境新建静态Flag任务。</p>
                        <p>2.如果是动态Flag任务，需要先删除之前的动态Flag任务，然后根据当前使用的环境新建动态Flag任务。</p>
                        <p>3.Checker任务需要根据当前使用的环境新建Checker任务</p>
                    </Alert>
                    <!--1:攻防赛，渗透演练需要任务-->
                    <FormItem label="任务类型">
                        <RadioGroup v-model="targetType" @on-change="changeType">
                            <Radio :label=1 :disabled="isUpdate">虚拟机靶标</Radio>
                            <Radio :label=0 :disabled="isUpdate">实物靶标</Radio>
                            <Radio :label=2 :disabled="isUpdate">分析靶标</Radio>
                        </RadioGroup>
                    </FormItem>
                    <FormItem label="任务" prop="questionId" v-if="targetType == 1" key="vm">
                        <Select filterable v-model="formValidate.questionId" placeholder="请选择任务" @on-change="setTeamQuestion" :disabled="targetModal.type == 2"
                                filterable>
                            <Option v-for="vm in allVms" :value="vm.id" :key="vm.id" :title="`${vm.name}(${vm.networkName})`">{{vm.name}}({{vm.networkName}})</Option>
                        </Select>
                    </FormItem>
                    <FormItem label="实物设备" prop="questionId" v-if="targetType == 0" key="phy">
                        <Select filterable v-model="formValidate.questionId" placeholder="请选择实物设备" filterable
                                @on-change="setTeamQuestion">
                            <Option v-for="item in allPhyDevices" :value="item.id" :key="item.id" :title="item.name">{{item.name}}</Option>
                        </Select>
                    </FormItem>
                    <FormItem label="任务显示名称" prop="name" key="name">
                        <Input v-model.trim="formValidate.name" placeholder="任务显示名称"></Input>
                    </FormItem>
                    <FormItem label="任务环境" prop="category" key="category">
                        <Input v-model.trim="formValidate.category" placeholder="任务环境" disabled></Input>
                    </FormItem>
                    <!--<FormItem label="靶标类型" prop="type" @on-change="formValidate.path == ''">
                      <RadioGroup v-model="formValidate.type">
                        <Radio :label=0>flag</Radio>
                        <Radio :label=1>多个虚拟机flag相同</Radio>
                        <Radio :label=2>多个虚拟机flag不同</Radio>
                        <Radio :label=3 >文档</Radio>
                      </RadioGroup>
                    </FormItem>-->
                    <!--<FormItem label="所属团队" prop="teamId">
                      <Select filterable  v-model="formValidate.teamId" placeholder="请选择团队" @on-change="changeTeamGroup">
                        <Option  v-for="item in accessGroupList" :value="item.id"  :key="item.id">{{item.name}}</Option>
                      </Select>
                    </FormItem>
                    <FormItem label="子网" prop="subnet">
                      <Select filterable  v-model="formValidate.subnet" placeholder="请选择子网" @on-change="changeSubnet">
                        <Option  v-for="item in subnetList" :value="item.id"  :key="item.id">{{item.name}}</Option>
                      </Select>
                    </FormItem>
                    <FormItem label="虚拟机" prop="vmId" v-show="formValidate.questionId">
                      <Select filterable v-model="formValidate.vmId" placeholder="请选择虚拟机" filterable @on-change="changeVm" ref="vmSelect">
                        <Option v-for="item in vmlists" :value="item.id" :key="item.id">{{item.name}}</Option>
                      </Select>
                    </FormItem>-->
                    <FormItem label="分值" prop="score" key="score">
                        <InputNumber :min="1" :max="1000" v-model="formValidate.score"
                                     placeholder="请输入分值"></InputNumber>
                        <!--<span style="color:#f90">
                            <Icon type="ios-information-circle-outline" />
                            本靶标的基础分
                        </span>-->
                    </FormItem>
                    <!--<FormItem  label="是否显示" prop="visibility">
                      <RadioGroup v-model="formValidate.visibility">
                        <Radio :label=1>显示</Radio>
                        <Radio :label=0>不显示</Radio>
                      </RadioGroup>
                      <span style="color:#f90"> <Icon type="ios-information-circle-outline" />用于在演练页面的展示控制</span>
                    </FormItem>-->
                    <!--渗透需要任务顺序-->
                    <FormItem label="排序" prop="sequence" v-if="type == 7 && stMode == 0">
                        <InputNumber v-model="formValidate.sequence" :min="1" placeholder="请输入排序"></InputNumber>
                    </FormItem>
                    <!--<FormItem label="flag路径" prop="path" v-if="formValidate.type == 0 && pathList.length > 0">
                      <Select filterable v-model="formValidate.path" placeholder="请输入路径">
                        <Option v-for="path in pathList" :value="path.addresses[0].applyFlagUrl" :key="path.id">{{path.addresses[0].applyFlagUrl}}</Option>
                      </Select>
                    </FormItem>-->
                    <!--<FormItem  label="访问方式" prop="access">
                      <RadioGroup v-model="access" @on-change="changeAccess">
                        <Radio label="1">内网访问</Radio>
                        <Radio label="2">映射访问</Radio>
                      </RadioGroup>
                    </FormItem>-->
                    <FormItem label="验证方式" prop="isNeedSubmitFlag" key="isNeedSubmitFlag">
                        <RadioGroup v-model="formValidate.isNeedSubmitFlag" @on-change="changeFlagType">
                            <Radio label="0">报告</Radio>
                            <Radio label="1">Flag</Radio>
                            <Radio label="2" v-show="targetType != 2">Checker</Radio>
                        </RadioGroup>
                    </FormItem>
                    <FormItem label="Checker任务" prop="scriptId"
                              v-if="formValidate.isNeedSubmitFlag == '2'" key="scriptId">
                        <Select filterable v-model="formValidate.scriptId" placeholder="请选择任务" @on-change="setTeamQuestion"
                                filterable>
                            <Option v-for="item in checkerList"
                                    :key="item.id"
                                    :value="item.id"
                                    @mouseenter.native="mouseOverConfiger($event,item.id)"
                                    @mouseleave.native="mouseLeaveConfiger($event,item.id)"
                                    @click.stop.prevent="configurationInformation=false">{{item.name}}</Option>
                        </Select>
                        <div v-show="configurationInformation" :style="{position:'absolute',left:cardPanelLeft,top:cardPanelTop,zIndex:'9999999999999999',}" @mouseenter="jinru" @mouseleave="yichu" @click.stop.prevent>
                            <Card :style="{minWidth:'350px',maxWidth:'600px'}"  >
                                <p slot="title" style="position:relative">
                                    <Icon type="ios-construct"></Icon>
                                    {{configPanel.configName}}
                                    <span slot="title" style="position:absolute;right:0px">
                                    <Icon type="ios-contact"></Icon>
                                    {{configPanel.configCreatorName}}
                                </span>
                                </p>
                                <ul>
                                    <li><span class="_dot"></span>path：{{configPanel.configPath}}</li>
                                    <li><span class="_dot"></span>argArr：{{configPanel.configArg}}</li>
                                    <li><span class="_dot"></span>cmd：{{configPanel.configCmd}}</li>
                                    <li><span class="_dot"></span>sysType：{{configPanel.configSystype}}</li>
                                    <li><span class="_dot"></span>protocol：{{configPanel.protocol}}</li>
                                    <li><span class="_dot"></span>serverPort：{{configPanel.serverPort}}</li>
                                    <li><span class="_dot"></span>language：{{configPanel.language}}</li>
                                    <li><span class="_dot"></span>CreateTime：{{configPanel.configCreateTime}}</li>
                                    <li><span class="_dot"></span>Desc：{{configPanel.configDescription}}</li>
                                </ul>
                            </Card>
                        </div>
                    </FormItem>
                    <div v-if="formValidate.isNeedSubmitFlag === '1'">
                        <FormItem label="验证类型" prop="isFixedFileFlag" v-if="formValidate.isNeedSubmitFlag==='1'"
                                  key="isFixedFileFlag">
                            <RadioGroup v-model="formValidate.isFixedFileFlag" @on-change="changeSubmitFlagType">
                                <Radio label="1" v-if="targetType != 2">静态Flag</Radio>
                                <Radio label="0" >固定Flag</Radio>
                            </RadioGroup>
                        </FormItem>
                        <FormItem label="可用Flag服务器" prop="flagServer" v-if="flagServerList.length">
                            <Select filterable v-model="flagServer" placeholder="请选择Flag服务器" filterable clearable>
                                <Option
                                    v-for="item in flagServerList"
                                    :key="item.id"
                                    :disabled="item.disabled"
                                    :value="item.id">{{item.name}}</Option>
                            </Select>
                        </FormItem>
                        <FormItem label="Flag路径" prop="flagPath" key="flagPath" v-if="targetType != 2&&formValidate.isFixedFileFlag==='1'">
                            <Input v-model.trim="formValidate.flagPath" placeholder="请输入路径"></Input>
                        </FormItem>
                        <FormItem label="Flag" prop="flag" v-if="formValidate.isFixedFileFlag==='0'"
                                  key="flag">
                            <Input type="textarea" v-model.trim="formValidate.flag"></Input>
                        </FormItem>
                    </div>
                    <FormItem label="内网IP" prop="ip" key="ip" v-if="targetType != 2">
                        <Input v-model.trim="formValidate.ip" placeholder="请输入IP" style="width:300px" disabled></Input>
                    </FormItem>
                    <FormItem label="内网服务端口" prop="servicePort" key="servicePort" v-if="targetType != 2">
                        <Input v-model.trim="formValidate.servicePort" placeholder="请输入PORT(1~65535)"
                               style="width:300px"></Input>
                    </FormItem>
                    <FormItem label="描述" prop="description" key="description">
                        <Input type="textarea" :maxlength="200" v-model.trim="formValidate.description"
                               placeholder="描述"></Input>
                    </FormItem>
                    <FormItem label="任务附件" prop="attachment" key="attachment">
                        <ctfFile
                                @setAttachmentFile="getAttachmentFile"
                                :curSaveFile="curSaveFile"
                                title="上传任务附件"></ctfFile>
                    </FormItem>
                    <!--<FormItem  label="服务内网端口" prop="portServer">
                      <Input v-model.trim="formValidate.portServer" placeholder="请输入PORT(1~65535)" style="width:300px"></Input>
                    </FormItem>-->
                    <!--<FormItem  label="访问跳转IP" prop="externalIp" v-if="access == '2'">
                      <Input v-model.trim="formValidate.externalIp" placeholder="请输入IP"></Input>
                    </FormItem>
                    <FormItem  label="跳转端口" prop="externalPort" v-if="access == '2'">
                      <Input v-model.trim="formValidate.externalPort" placeholder="请输入PORT(1~65535)" style="width:300px"></Input>
                    </FormItem>-->
                </Form>
            </Modal>
            </search-table>
</template>

<script>
    import {
        getTargetTeamList_new,
        addTargetTeam_new,
        modifyTargetTeam_new,
        delTargetTeam_new,
        getSceneInfo,
        queryVmWithParty,
        getPhyDevNodeList,
    } from '@/api/drill_compete'
    import {queryCtfList} from '@/api/question'
    import {getFlagServerList, getstatusbyprjid, queryTargetList, loadConfiguration} from '@/api/drill'
    import CtfFile from '@/view/resourceManagement/questions/ctfQuestion/ctfFile_new.vue'
    import {getaccessgrouplist,getAllRanges} from '@/api/access_new'
    import { getImageData } from '@/api/image'

    export default {
        name: 'scenes',
        props: ['type', 'disabledAllBtn','isDistributed','drillDetailProgress'],
        components: { CtfFile},
        data() {
            const validateNum = (rule, value, callback) => { //验证只能填入数字
                if (value) {
                    if (!Number.isInteger(value)) {
                        callback(new Error('请输入整数'));
                    } else if (value < 0 || value > 1000) {
                        callback(new Error('请输入1~1000的整数'));
                    } else {
                        callback()
                    }
                } else {
                    callback(new Error('请输入1~1000的整数'));
                }
            }
            const validatePort = (rule, value, callback) => { //验证只能填入数字
                var reg = new RegExp("^(([1-9]\\d{0,3})|([1-5]\\d{4})|(6[0-4]\\d{3})|(65[0-4]\\d{2})|(655[0-2]\\d)|(6553[0-5]))$");
                //验证警戒值
                if (value) {
                    if (!reg.test(Number(value))) {
                        callback(new Error('请输入1-65535的整数'));
                    } else {
                        callback()
                    }
                } else {
                    callback()
                }
            }
            const validateIP = (rule, value, callback) => { //验证只能填入数字
                var reg = new RegExp("^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$");
                //验证警戒值
                if (value) {
                    if (!reg.test(value)) {
                        callback(new Error('ip格式错误'));
                    } else {
                        callback()
                    }
                } else {
                    callback()
                }
            }
            return {
                flagServer: '',
                flagServerList: [],
                isUpdate: false,
                curSaveFile: {}, // 已保存的附件信息
                attachmentFile: {}, // 待上传的附件信息
                hoverCdraBol: false,
                cardPanelLeft:'3px',
                cardPanelTop:'3px',
                configurationInformation: false,
                configPanel:{
                    configPath:'',
                    configSystype:'',
                    configContent:'',
                    configDescription:'',
                    configCreateTime:'',
                    configCreatorName:'',
                    configName:'',
                    configType:'',
                    configArg:'',
                    configCmd:'',
                    protocol:'',
                    serverPort:'',
                    language:'',
                },
                routeParams: {
                    id: this.$route.query.id,
                    prjid: this.$route.query.prjid
                },
                targetModal: {
                    show: false,
                    title: '',
                    loading: true,
                    type: 1 //1添加，2修改
                },
                pathList: [],
//		accessGroupList:[],
//      vmlists:[],
//      teamlists:[],
                queryTargetTeamInfo: {
                    pageIndex: 1,
                    pageSize: 10,
                    sceneId: this.$route.query.id,
                    projectId: this.$route.query.prjid,
                    order: 'asc',
                    sortBy: 'sequence'
                },
                questionList: [],
                access: '1',
                formValidate: {
                    scriptId: '', // 选中的checker
                    //"createTime": "2020-02-10T03:35:50.081Z",
                    //"creator": "string",
                    "description": "", //描述
                    "externalIp": "", //对外ip
                    "externalPort": "", //对外端口
                    //"ip": "string",
                    "name": "", //任务显示名称
                    //"password": "string",
                    "port": "",
                    "rangeId":'',
                    "projectId": this.$route.query.prjid,
                    "questionId": '', //任务id
                    "sceneId": this.$route.query.id,
                    "score": 1,
                    //"status": 0, //状态：1 正常/防护成功，2 被攻破，3 服务异常，4 被攻破+服务异常
                    //"teamId": "",
                    //"teamName": "",
                    "type": 0, //靶标类型：0.实物，1.靶标
                    //"user": "string",
                    "visibility": 0, //可见性：是否可见- 0.不可见 1可见
                    //"vmId": "",
                    "flagPath": "/opt/flag.txt",
                    "sequence": 1,
                    "servicePort": "",
                    "isFixedFileFlag": "1",
                    "isNeedSubmitFlag": "1",
                    "flag": "",
                    category: ''
                },
                oldFormValidate: {},
                ruleValidate: {
                    scriptId: [
                        { required: true, message: 'Checker任务不能为空', trigger: 'change' }
                    ],
                    name: [
                        {required: true, message: '名字不能为空', trigger: 'change'}
                    ],
//        description: [
//          { required: true, message: '请输入描述信息', trigger: 'change' }
//        ],
                    type: [
                        {required: true, type: 'number', message: '请选择靶标类型', trigger: 'change'},
                    ],
                    score: [
                        { required: true,type:'number',message: '请输入分值', trigger: 'change' },
                        {validator: validateNum, trigger: 'change'}
                    ],
//        flagPath:[
//          { required: true ,message: '请输入路径', trigger: 'change'}
//        ],
//        externalIp:[
//        	{ required: true, message: '请输入对外IP', trigger: 'change'}
//        ],
//        externalPort:[
//        	{ required: true, type:'number',message: '请输入对外端口', trigger: 'change'}
//        ],
                    sequence: [
                        {required: true, type: 'number', message: '请设置排序', trigger: 'change'}
                    ],
                    questionId: [
                        {required: true, message: '请选择任务', trigger: 'change'}
                    ],
                    flag: [
                        {required: true, message: '请输入Flag', trigger: 'change'}
                    ],
                    ip: [
                        {validator: validateIP, trigger: 'change'}
                    ],
                    servicePort: [
                        {validator: validatePort, trigger: 'change'}
                    ]
//        visibility:[
//        	{ required: true, type:'number',message: '请选择', trigger: 'change'}
//        ],
//        vmId:[
//        	{ required: true, message: '请选择虚拟机', trigger: 'change'}
//        ],
//        teamId:[
//        	{ required: true, message: '请选择团队', trigger: 'change'}
//        ],
                },
                initTargetObjData: {
                    "createtime": "",
                    "createuser": localStorage.getItem('username'),
                    "frequency": 0,
                    "id": "",
                    "isshow": 1,
                    "lastupdatetime": "",
                    "modifier": "",
                    "sceneid": "",
                    "targetdes": "",
                    "targetname": "",
                    "targetsubmittype": 0,
                    "targettype": 0,
                    "teamid": "",
                    "type": 0,
                    "uri": "",
                    "vmid": "",
                    "score": '0'
                },
                querytime: {},
                targetTeamCol: [
                    {
                        title: '任务显示名称',
                        key: 'name',
                        align: 'center',
                        ellipsis: true,
                        tooltip: true,
                        placement: 'top-left',
                        width: 240
//          width:100
                    },
                    {
                        title: '内网IP',
                        key: 'ip',
                        align: 'center',
                        ellipsis: true,
                        tooltip: true,
                        width: 100
                    },
                    {
                        title: '内网服务端口',
                        key: 'servicePort',
                        align: 'center',
                        ellipsis: true,
                        tooltip: true,
                        width: 60
                    },
                    {
                        title: '路径',
                        key: 'flagPath',
                        align: 'center',
                        tooltip: true,
                        width: 100
                    },
                    {
                        title: '分值',
                        key: 'score',
                        align: 'center',
                        ellipsis: true,
                        tooltip: true,
                        width: 60
                    },
                    {
                        title: '验证类型',
                        key: 'isFixedFileFlag',
                        align: 'center',
                        ellipsis: true,
                        tooltip: true,
                        width: 60,
                        render: (h, params) => {
                            return h('span', this.typeFilter(params.row.isFixedFileFlag))
                        }
                    },
                    {
                        title: '任务类型',
                        key: 'type',
                        align: 'center',
                        ellipsis: true,
                        tooltip: true,
                        width: 60,
                        placement: 'top-left',
                        render: (h, params) => {
                            return h('span', params.row.type == 1 ? '虚拟机靶标' : params.row.type == 2 ? '分析靶标' : '实物靶标')
                        }
                    },
                    {
                        title: 'Flag',
                        key: 'flag',
                        tooltip: true,
                        width: 100
                    },
                    {
                        type:'link',
                        key:'fileName',
                        title: '附件',
                        width: 100,
                        setPath:(data) => {
                            return `/api/minio/download/${data.fileId}`
                        },
                        tooltip:true
                        // render: (h, params) => {
                        //     let fileName = params.row.fileName || '-'
                        //     let fileId = params.row.fileId || ''
                        //     if (fileId && fileName) {
                        //         return h('Tooltip',{
                        //             props:{
                        //                 maxWidth:400,
                        //                 placement:'top',
                        //                 triggle:'hover',
                        //                 transfer:true
                        //             }
                        //         },[
                        //             h('a',{
                        //                 'class':'showContent',
                        //                 style:{
                        //                     width:'100px',
                        //                     display: 'inline-block'
                        //                 },
                        //                 attrs: {
                        //                     href: `/api/minio/download/${fileId}`
                        //                 }
                        //             }, fileName),
                        //             h('div',{
                        //                 'class':'tooltipContent',
                        //                 slot:'content'
                        //             }, fileName)
                        //         ])
                        //     } else {
                        //         return h('span', fileName)
                        //     }
                        // }
                    },
                    {
                        title: '描述',
                        key: 'description',
                        align: 'center',
                        width: 100,
                        tooltip: true,
                    },
                    {
                        title: '操作',
                        key: 'action',
                        width: 200,
                        placement: 'top-right',
                        opList:[
                            {
                                txt:'修改',
                                type:'modify',
                                disabled: () => this.disabledAllBtn||this.drillDetailProgress!=0,
                                fun:this.showAddAndUpdate
                            },
                            {
                                txt:'删除',
                                type:'delete',
                                tooltip:true,
                                disabled: () => this.disabledAllBtn||this.drillDetailProgress!=0,
                                fun:(data) => {
                                    this.delTargetTeam(data.id)
                                },
                                title: '你确定要删除吗?'
                            }
                        ],
//                         render: (h, params) => {
//                             return h('div', [
//                                 h('Button', {
//                                     props: {
//                                         type: 'text',
//                                         size: 'small',
//                                         disabled: this.disabledAllBtn||this.drillDetailProgress!=0
//                                     },
//                                     attrs: {
//                                         title: '修改'
//                                     },
//                                     style: {
//                                         border: 'none',
//                                         background: 'none',
//                                         boxShadow: 'none'
//                                     },
//                                     on: {
//                                         click: () => {
//                                             this.showAddAndUpdate(params.row)
//                                         }
//                                     }
//                                 }, [
//                                     h('img', {
//                                         attrs: {
// //                          src: !this.setReBtnStatus(params.row) ? require('../../../assets/globalIcon/modify.png'):require('../../../assets/globalIcon/dis-modify2.png'),
//                                             src: this.disabledAllBtn||this.drillDetailProgress!=0 ? require('../../../../assets/project/modifys.png') : require('../../../../assets/project/modifys-h.png')
//                                         },
//                                         style: {
//                                             cursor: 'pointer',
// //			                            'margin-right':'5px',
//                                             'vertical-align': 'middle',
// //			                            width:'16px',
// //			                            height:'auto',
//                                             display: 'inline-block',
//                                             marginBottom: '4px',
//                                         },
//                                     }),
// //	                h('span',{
// //	                    style: {
// //	                        cursor: 'pointer',
// //	//                          color:!this.setReBtnStatus(params.row) ? '#2d8cf0' : '#c5c8ce'
// //													color:'#2d8cf0'
// //	                    },
// //	                },'修改')
//                                 ]),
//                                 h('Poptip', {
//                                     props: {
//                                         disabled: this.disabledAllBtn,
//                                         confirm: true,
//                                         'ok-text': "确定",
//                                         'cancel-text': "取消",
//                                         type: 'error',
//                                         size: 'large',
//                                         title: '你确定要删除吗?',
//                                         transfer: true
//                                     },
//                                     on: {
//                                         'on-ok': () => {
//                                             this.delTargetTeam(params.row.id)
//                                         }
//                                     }
//                                 }, [
//                                     h('Button', {
//                                         props: {
//                                             type: 'text',
//                                             size: 'small',
//                                             disabled: this.disabledAllBtn||this.drillDetailProgress!=0
//                                         },
//                                         attrs: {
//                                             title: '删除'
//                                         },
//                                         style: {
//                                             border: 'none',
//                                             background: 'none',
//                                             boxShadow: 'none'
//                                         },
//                                     }, [
//                                         h('img', {
//                                             attrs: {
// //                          src: !this.setReBtnStatus(params.row) ?require('../../../assets/globalIcon/del.png'):require('../../../assets/globalIcon/dis-del.png'),
//                                                 src: this.disabledAllBtn||this.drillDetailProgress!=0 ? require('../../../../assets/project/delNote-d.png') : require('../../../../assets/project/delNote-h.png')
//                                             },
//                                             style: {
//                                                 cursor: 'pointer',
// //				                            'margin-right':'5px',
//                                                 'vertical-align': 'middle',
// //				                            width:'16px',
// //				                            height:'auto',
//                                                 display: 'inline-block',
//                                                 marginBottom: '4px',
//                                             },
//                                         }),
// //                  h('span',{
// //                      style: {
// //                          cursor: 'pointer',
// ////                          color:!this.setReBtnStatus(params.row) ? '#2d8cf0' : '#c5c8ce'
// //														color:'#2d8cf0'
// //                      },
// //                  },'删除')
//                                     ])
//                                 ])
//                             ])
//                         }

                    }
                ],
                allTargetTeamData: [],
                targetTeamData: [],
                targetTeamTotal: 0,
                TargetId: '',
//      subnetList:[],
//      subnet:''
                sceneInfo: {},
                stMode: 0,
                allVms: [],
                targetList: [],
                allPhyDevices: [],
                targetType: 1,
                checkerList: [] // checker列表
            }
        },
        filters: {},
        computed: {
            showQuestionList() {
//			let quesList = [];
//			this.questionList.forEach(ques => {
//				if(this.allVms.map(vm => vm.imageId).includes(ques.imageId)){
//					ques.id = ques.chaId;
//					ques.type = 'question';
//					quesList.push(ques)
//				}
//			})
//			this.targetList.forEach(target => {
//				if(this.allVms.map(vm => vm.imageId).includes(target.imageId)){
//					target.type = 'target';
//					target.id = target.targetId;
//					target.name = target.targetName;
//					quesList.push(target)
//				}
//			})
//			return quesList;
            }
        },
        watch: {
            flagServer(newValue) {
                this.setFlagServerPath(newValue, this.formValidate.questionId)
            },
            'formValidate.questionId': function(newValue) {
                if(!newValue){
                    return
                }
                this.flagServer = ''
                const res =  this.allVms.filter(item=>item.id==this.formValidate.questionId)
                if(res && res[0] && res[0].name){
                  this.formValidate.category = `${res[0].name}(${res[0].networkName})`
                }

                this.changeSubmitFlagType(this.formValidate.isFixedFileFlag)
            }
        },
        mounted() {
            this.getAllRanges()
            //this.getAllSence()
            //this.getAllTargetHost();
//  	this.getProjectInfo();
//  	this.getAccessGroupList();
            this.getAllVmlist(true);
            this.getPhyDevNodeList();
            getSceneInfo(this.$route.query.id).then(data => {
                if (data.code == 1) {
                    this.sceneInfo = data.data;
                    this.stMode = JSON.parse(data.data.extension).stMode;
                    if (this.stMode == 0) {
                        this.targetTeamCol.splice(0, 0, {
                            title: '排序',
                            key: 'sequence',
                            align: 'center',
                            ellipsis: true,
                            width: 60
                        });
                    }
                }
            });
            //this.queryCtfQuestionList();
            this.getTargetTeamList();
            this.getAllTargetTeamList()
            this.getFlagServerList()

            //this.queryTargetList()
        },
        methods: {
            getAllRanges(){
                console.log();
				getAllRanges().then(res=>{
					if(res.code==1){
						this.rangeList=res.data
						if(this.isDistributed!=1){
							let selfRange={}
							this.selfRange=this.rangeList.find((item=>{
									if(item.self=='0'){
										return item
									}
							}))
							this.rangeList=[]
							this.rangeList.push(this.selfRange)
						}
							this.rangeId = this.rangeList[0].id;
                            console.log(this.rangeId,'this.rangeIdthis.rangeId');

					} else{
						this.$Message.warning('查询靶场失败')
					}
				}).finally(() => {

				})
			},
            setFlagServerPath(flagServerId, quetsionId) {
                let flagServer = this.flagServerList.find(item => item.id === flagServerId)
                let applyFlagUrl = flagServer && flagServer.addresses && flagServer.addresses[0] && flagServer.addresses[0].applyFlagUrl
                if (!applyFlagUrl || !quetsionId) { // 没有flag服务器或者没有题目，不做处理
                    return
                }
                let vm = this.allVms.find(item => item.id === quetsionId)
                getImageData({ id: vm.imageId }, { pageIndex: 1, pageSize: 10 }).then(({ data = {} }) => {
                    let item
                    if (data.code === 1) {
                        item = data.data && data.data.items && data.data.items[0]
                    }
                    if (item && item.osType === 'windows') {
                        this.$set(this.formValidate, 'flagPath', applyFlagUrl + '/html')
                    } else {
                        this.$set(this.formValidate, 'flagPath', applyFlagUrl)
                    }
                })
            },
            //获取上传附件信息
            getAttachmentFile(file){
                if(file){
                    this.attachmentFile = {
                        filePath:file.data,
                        fileName:file.info.originalName,
                        fileId:file.info.id
                    };
                }else{
                    this.attachmentFile = {};
                }
            },
            jinru(){
                this.hoverCdraBol = true
            },
            yichu(){
                this.hoverCdraBol = false
                this.configurationInformation = false
                this.cardPanelLeft = '0'
                this.cardPanelTop = '0'
            },
            mouseLeaveConfiger(ev,value){
                clearTimeout(this.optionOutEvent)
                this.optionOutEvent = setTimeout(() => {
                    if(!this.hoverCdraBol){
                        this.configurationInformation = false
                        this.cardPanelLeft = '0'
                        this.cardPanelTop = '0'
                    }
                }, 300);
            },
            mouseOverConfiger(e,value){
                clearTimeout(this.optionHoverEvent)
                this.optionHoverEvent = setTimeout(() => {
                    if(this.hoverCdraBol){
                        return;
                    }
                    this.configurationInformation = true
                    this.cardPanelLeft = e.layerX +30+ 'px'
                    this.cardPanelTop = e.layerY +35+'px'
                    //查询配置详细信息
                    let template = this.checkerList.find(item => {
                        return item.id === value
                    })
                    if (template) {
                        this.configPanel.configName = template.name
                        this.configPanel.configPath = template.path
                        this.configPanel.configSystype = template.sysType
                        this.configPanel.configArg = template.argArr
                        this.configPanel.configCmd = template.cmd
                        this.configPanel.protocol = template.protocol
                        this.configPanel.serverPort = template.serverPort
                        this.configPanel.language = template.language
                        this.configPanel.configDescription = template.description
                        this.configPanel.configCreateTime = template.createTime
                        this.configPanel.configCreatorName = template.creatorName
                    }
                }, 300);
            },
            // 获取配置的checkerList
            getCheckerList() {
                loadConfiguration({
                    pageSize: 2147483646
                }).then(({code, data, message}) => {
                    if (code === 1) {
                        this.checkerList = data.items
                    } else {
                        if (message) {
                            this.$Message.warning(message)
                        }
                    }
                })
            },
            initData() {
                this.flagServer = ''
                this.targetType = 1
                this.formValidate = {
                    scriptId: '',
                    //"createTime": "2020-02-10T03:35:50.081Z",
                    //"creator": "string",
                    "description": "", //描述
                    "externalIp": "", //对外ip
                    "externalPort": "", //对外端口
                    //"ip": "string",
                    "name": "", //任务显示名称
                    //"password": "string",
                    "port": "",
                    "projectId": this.$route.query.prjid,
                    "questionId": '', //任务id
                    "sceneId": this.$route.query.id,
                    "score": 1,
                    //"status": 0, //状态：1 正常/防护成功，2 被攻破，3 服务异常，4 被攻破+服务异常
//			  "teamId": "",
//			  "teamName": "",
                    "type": 1, //靶标类型：0.单个虚拟机、1.多个虚拟机flag相同、2.多个虚拟机flag不同、3.文件类型
                    //"user": "string",
                    "visibility": 0, //可见性：是否可见- 0.不可见 1可见
//			  "vmId": "",
                    "flagPath": "/opt/flag.txt",
                    "sequence": 1,
                    "servicePort": '',
//			  "subnet":"",
                    "isFixedFileFlag": "1",
                    "isNeedSubmitFlag": "1",
                    "flag": "",
                    category: ''
                }
            },
//  	getProjectInfo(){
//			getstatusbyprjid(this.$route.query.prjid).then(data => {
//				if(data.code == 1){
//					this.projectInfo = data.attribute;
//				}
//			})
//		},
            showAddAndUpdate(info) {
                console.log(info,'infoinfo');
                this.initData();
                this.getCheckerList()
                if (!info) {
                    this.targetModal.title = '添加任务';
                    this.targetModal.type = 1;
                    this.access = "1";
                    this.curSaveFile = {}
                    this.attachmentFile = {}
                    this.isUpdate = false
                } else {
                    this.targetModal.title = '修改任务';
                    this.isUpdate = true
                    this.targetModal.type = 2;
                    this.formValidate = JSON.parse(JSON.stringify(info));
                    this.targetType = this.formValidate.type
                    this.curSaveFile = {
                        info:{
                            originalName: info.fileName,
                            id: info.fileId,
                        },
                        data: info.filePath
                    }
                    this.attachmentFile = {
                        filePath: info.filePath,
                        fileName: info.fileName,
                        fileId: info.fileId
                    };
                    if(this.isDistributed==1){
                        this.flagServerList.forEach(item => {
                            item.disabled = item.rangeId !== info.rangeId
                        })
                    }
                    this.question = {imageId: this.formValidate.imageId};
                    if (this.formValidate.externalPort || this.formValidate.externalIp) {
                        this.access = "2";
                    } else {
                        this.access = "1";
                    }
                }
                // 改变formValidate.questionId的值会重置flagPath，需要单独再设置一次
                this.$nextTick(() => {
                    if (this.isUpdate) {
                        this.formValidate.flagPath = info.flagPath
                    }
                    this.targetModal.show = true;
                })
            },
            addTargetTeam() {
                let params = JSON.parse(JSON.stringify(this.formValidate));
                // console.log(params,'paramsparamsparams');
                if (params.isNeedSubmitFlag !== "1") { // 0:报告; 1:flag; 2: checker
                    if (params.isNeedSubmitFlag === '0') { // 报告
                        params.isFixedFileFlag = "3"; // 0:固定Flag; 1:静态Flag; 2:Checker; 3:提交报告
                    } else { // checker
                        params.isFixedFileFlag = "2"; // 0:固定Flag; 1:静态Flag; 2:Checker; 3:提交报告
                    }
                    params.flag = '';
                    params.flagPath = '';
                } else { // flag
                    if (params.isFixedFileFlag === "1") {
                        params.flag = '';
                    }
                }
                params.type = this.targetType;
//	  		params.targetTempInfos = [];
//	  		params.questionName = this.question.name;
//	  		if(this.formValidate.portServer){  //如果有路径，添加团队临时信息
//	  			params.targetTempInfos.push(
//				    {
//				      "id": "",
//				      "info": this.formValidate.portServer,
//				      "targetId": "",
//				      "type": 3  //服务内网端口
//				    }
//				)
//	  		}
//	  		if(this.formValidate.path){ //如果有路径，添加团队临时信息
//		  		params.targetTempInfos.push(
//				    {
//				      "id": '',
//				      "info": this.formValidate.path,
//				      "targetId":'',
//				      "type": 1 //flag路径
//				    }
//				)
//			}
                addTargetTeam_new(params).then(data => {
                    if (data.code == 1) {
                        // 添加成功后清空搜索条件，回退到首页
                        this.queryTargetTeamInfo.pageIndex = 1
                        this.getTargetTeamList();
                        this.getAllTargetTeamList()
                        this.$Message.info('操作成功');
                        this.handleReset('formValidate');
                        this.targetModal.show = false;
                    } else {
                        this.$Message.warning(data.message)
                        this.cancelLoading('targetModal');
                    }
                }).catch(error => {
                    this.cancelLoading('targetModal');
                })
            },
            modifyTargetTeam() {
                let params = JSON.parse(JSON.stringify(this.formValidate));
                if (params.isNeedSubmitFlag !== "1") { // 0:报告; 1:flag; 2: checker
                    if (params.isNeedSubmitFlag === '0') { // 报告
                        params.isFixedFileFlag = "3"; // 0:固定Flag; 1:静态Flag; 2:Checker; 3:提交报告
                    } else { // checker
                        params.isFixedFileFlag = "2"; // 0:固定Flag; 1:静态Flag; 2:Checker; 3:提交报告
                    }
                    params.flag = '';
                    params.flagPath = '';
                } else { // flag
                    if (params.isFixedFileFlag === "1") {
                        params.flag = '';
                    }
                }
                params.type = this.targetType;
//	  		params.targetTempInfos = [];
//	  		params.questionName = this.question.name;
//	  		let id = '';
//	  		if(this.formValidate.targetTempInfos.filter(temp => temp.type == 1).length > 0){
//	  			id = this.formValidate.targetTempInfos[0].id
//	  		}
//	  		if(this.formValidate.path){ //如果有路径，添加团队临时信息
//		  		params.targetTempInfos.push(
//				    {
//				      "id": id,
//				      "info": this.formValidate.path,
//				      "targetId":params.id,
//				      "type": 1 //flag路径
//				    }
//				)
//			}
//	  		if(this.access == "1"){
//	    		params.externalPort = '';
//    			params.externalIp = '';
//	    	}else{
//	    		params.port = '';
//	    	}
                modifyTargetTeam_new(params).then(data => {
                    if (data.code == 1) {
                        this.getTargetTeamList();
                        this.getAllTargetTeamList()
                        this.$Message.info('操作成功');
                        this.handleReset('formValidate');
                        this.targetModal.show = false;
                    } else {
                        this.$Message.warning(data.message)
                        this.cancelLoading('targetModal');
                    }
                }).catch(error => {
                    this.cancelLoading('targetModal');
                })
            },
            saveTargetTeam() {
                this.$refs['formValidate'].validate((valid) => {
                    if (valid) {
                        // 不是checker检测，清空checker属性
                        if (this.formValidate.isNeedSubmitFlag !== '2') {
                            this.formValidate.scriptId = ''
                        } else {
                            this.formValidate.isFixedFileFlag = "2"
                        }
                        if (this.attachmentFile.fileId) { // 存在附件，将附件信息存入formValidate
                            this.formValidate = Object.assign(this.formValidate, this.attachmentFile)
                            this.formValidate.isExistTips = 1
                        } else { // 没有附件，确保formValidate中没有残余信息
                            delete this.formValidate.fileId
                            delete this.formValidate.fileName
                            delete this.formValidate.filePath
                            this.formValidate.isExistTips = 0
                        }
                        if(this.targetType==1){
                            this.formValidate.rangeId =(this.allVms.find(itme=>itme.id===this.formValidate.questionId) || {}).rangeId
                        } else if(this.targetType==0){
                            this.formValidate.rangeId =(this.allPhyDevices.find(itme=>itme.id===this.formValidate.questionId) || {}).rangeId
                        } else{
                            this.formValidate.rangeId=undefined
                        }
                        // console.log(this.formValidate,'this.formValidatethis.formValidatethis.formValidatethis.formValidate');
                        if (this.targetModal.type == 1) {
                            this.addTargetTeam();
                        } else {
                            this.modifyTargetTeam();
                        }
                    } else {
                        this.cancelLoading('targetModal');
                    }
                })
            },
            getAllTargetTeamList() {
                getTargetTeamList_new({
                    pageIndex: 1,
                    pageSize: 2147483647,
                    sceneId: this.$route.query.id,
                    projectId: this.$route.query.prjid
                }).then(data => {
                    if (data.code == 1) {
                        this.allTargetTeamData = data.data.items || data.data;
                    } else {

                    }
                })
            },
            getTargetTeamList() {
                getTargetTeamList_new(this.queryTargetTeamInfo).then(data => {
                    if (data.code == 1) {
                        this.targetTeamData = data.data.items || data.data;
                        this.targetTeamTotal = data.data.total;
                    } else {

                    }
                })
            },
            delTargetTeam(id) {
                delTargetTeam_new(id).then(data => {
                    if (data.code == 1) {
                        // 删除后展示当前页，当前页没有数据展示前一页
                        this.queryTargetTeamInfo.pageIndex = (this.targetTeamData.length == 1 && this.queryTargetTeamInfo.pageIndex > 1) ?
                            this.queryTargetTeamInfo.pageIndex - 1 : this.queryTargetTeamInfo.pageIndex;
                        this.getTargetTeamList();
                        this.getAllTargetTeamList()
                    } else {

                    }
                })
            },
            cancelLoading(name) {
                this[name].loading = false;
                setTimeout(() => {
                    this[name].loading = true;
                })
            },
            getAllVmlist(setAll) {
                let params = {
                    page: 1,
                    pageSize: 10000,
                    sortBy: 'name',
                    order: 'asc',
                    findPorts: true,
                }
//	        let params = {
//	        	page:1,
//	        	rows:10000,
//	        	sortBy:'name',
//				order:'asc',
//	        	projectId:this.routeParams.prjid,
//	        }
                if (this.question) {
                    params.imageId = this.question.imageId;
                }
                if (this.group) {
                    //params.party = this.group.partyId;
                }
//	        params.networkId = this.formValidate.subnet;
                queryVmWithParty(this.routeParams.prjid, params).then(data => {
//		    getProjectSevers(params).then(data => {
                    if (data.code == 1) {
                        if (setAll) {
                            this.allVms = data.data.list || data.data;
                        } else {
                            let vmlists = data.data.list || data.data;
                            let vm = vmlists.filter(vm => vm.imageId == this.question.imageId);
                            if (vm.length > 0) {
                                this.formValidate.ip = vm[0].address[0].ips[0].ipAddress;
                                this.formValidate.name = vm[0].name;
                            }
                        }
                        console.log(this.allVms,'this.allVmsthis.allVmsthis.allVms');
                        //this.getVmIp(this.formValidate.vmId);
//					if(this.vmlists.length > 0){
//						let server = this.vmlists.filter(vm => vm.id == this.formValidate.vmId)[0];
//	    		        if(server){
//	    		        	this.formValidate.subnet = server.addresses[0].subnetId;
//	    		        	this.getFlagServerList(server.address[0].ipv4);
//	    		        	this.getFlagServerList(server.addresses[0].ip);
//	    		        }
//					}
                    }
                })
            },
            getPhyDevNodeList() {
                let params = {
                    page: 1,
                    pageSize: 10000,
                    sortBy: 'name',
                    order: 'asc',
                    projectId: this.$route.query.prjid,
                    findPorts: true,
                }
                getPhyDevNodeList(params).then(data => {
                    if (data.code == 1) {
                        this.allPhyDevices = data.data.list;
                    } else {

                    }
                })
            },
//	    getAccessGroupList(){
//			if(!this.routeParams.id){
//				return;
//			}
//			let params = {
//				pageIndex:1,
//				pageSize:2147483647,
//				testId:this.routeParams.id
//			};
//			this.selectGroupList = [];
//			getaccessgrouplist(params).then(data => {
//				if(data.code == 1){
//					this.accessGroupList = data.data.items;
//				}else if(data.code == -2) {
//					this.accessGroupList = [];
//				}else{
//					this.$Message.warning(data.message);
//				}
//			})
//		},
            getTargetSize(size) {
                this.queryTargetTeamInfo.pageSize = size;
                this.getTargetTeamList()
            },
            getTargetPage(page) {
                console.log(page,'pagepage');
                this.queryTargetTeamInfo.pageIndex = page;
                this.getTargetTeamList()
            },
            changeFlagType(type) {
                if (type == 1 && this.targetType == 2) {
                    this.formValidate.isFixedFileFlag = '0'
                } else {
                    this.formValidate.isFixedFileFlag = '1'
                }
            },
            setTeamQuestion(val) {
                if (!val) {
                    return
                }
//	    	this.question = this.showQuestionList.filter(question => question.id == val)[0];
                if (this.formValidate.type == 1) { //靶标
                    let vm = this.allVms.filter(vm => vm.id == val);
                    if (vm.length > 0) {
                        this.formValidate.ip = vm[0].address[0].ips[0].ipAddress;
                        this.formValidate.name = vm[0].name;
                        this.formValidate.imageId = vm[0].imageId;
                        this.formValidate.imageName = vm[0].imageName;
                        this.flagServerList.forEach(item => {
                            item.disabled = item.rangeId !== vm[0].rangeId
                        })
                    } else {
                        this.flagServerList.forEach(item => {
                            item.disabled = false
                        })
                    }
                } else {
                    let vm = this.allPhyDevices.filter(vm => vm.id == val);
                    if (vm.length > 0) {
                        this.formValidate.name = vm[0].name;
                        this.flagServerList.forEach(item => {
                            item.disabled = item.rangeId !== vm[0].rangeId
                        })
                      let a = vm
                      if(a[0].addresses && a[0].addresses[0] && a[0].addresses[0].ips && a[0].addresses[0].ips[0] && a[0].addresses[0].ips[0].ipAddress){
                        this.formValidate.ip = a[0].addresses[0].ips[0].ipAddress;
                        console.log('this.formValidate.ip',this.formValidate.ip)
                      }



                    } else {
                        this.flagServerList.forEach(item => {
                            item.disabled = false
                        })
                    }
                }
//	    	this.getAllVmlist();
            },
            // 是否属于windows系统
            isWinSystem(systemType) {
                if (systemType) {
                    return systemType.toLowerCase().includes('win')
                } else {
                    return true
                }
            },
            changeType(type) {
                this.targetType = type;
                this.formValidate = {
                    "description": "", //描述
                    "externalIp": "", //对外ip
                    "externalPort": "", //对外端口
                    "name": "", //任务显示名称
                    "port": "",
                    "projectId": this.$route.query.prjid,
                    "rangeId":'',
                    "questionId": '', //任务id
                    "sceneId": this.$route.query.id,
                    "score": 1,
                    "type": type, //靶标类型：0.单个虚拟机、1.多个虚拟机flag相同、2.多个虚拟机flag不同、3.文件类型
                    "visibility": 0, //可见性：是否可见- 0.不可见 1可见
                    "flagPath": "/opt/flag.txt",
                    "sequence": 1,
                    "servicePort": "",
                    "isFixedFileFlag": "1",
                    "isNeedSubmitFlag": "1",
                    "flag": "",
                    category: ''
                }
                if (type == 2) {
                    this.formValidate.isFixedFileFlag = '0'
                    this.formValidate.flagPath = ''
                }
            },
            changeSubmitFlagType(type) {
                if (type == 0) {
                    this.formValidate.flagPath = "";
                } else {
                    if ((this.formValidate.type == 1 || this.formValidate.type == 0) && !this.flagServer) { // 虚拟机靶标、实物靶标切换时，没有设置flag服务器，需要自动设置flag路径
                        let template = this.allVms.find(item => item.id === this.formValidate.questionId)
                        if (template && this.isWinSystem(template.sysType)) {
                            this.$set(this.formValidate, 'flagPath', 'c:/flag.txt')
                        } else {
                            this.$set(this.formValidate, 'flagPath', '/opt/flag.txt')
                        }
                    }
                }
            },
//	    changeTeamGroup(val){
//	    	this.formValidate.vmId = '';
//	    	if(!val){
//	    		return
//	    	}
//	    	this.setTeamGroup(val);
//	    },
//	    setTeamGroup(val){
//	    	if(!val){
//	    		return
//	    	}
//	    	this.group =  this.accessGroupList.filter(group => group.id == val)[0];
//	    	this.formValidate.teamName = this.group.name;
//	    	this.getAllVmlist();
//	    },
//	    changeSubnet(){
//	    	this.formValidate.vmId = '';
//	    	this.getAllVmlist();
//	    },
            handleReset(name) {
                //this.$refs[name].resetFields();
                //    this.addTarget = false;
                this.initData();
                this.$refs[name].fields.forEach(function (e) {
                    if (e.fieldValue != undefined && e.fieldValue != '') {
                        e.resetField()
                    }
                })
            },
            queryCtfQuestionList() {//查询ctf题列表-不分页--需要环境
                let obj = {
                    pageIndex: 1,
                    pageSize: 2147483647,
                    isNeedEnv: '1',
                    //visibility:'share',
                    //isNeedSubmitFlag:'1',
                    //category:this.autoPro.ctfType.join(',')
                };
                let _this = this;
                queryCtfList(obj).then(data => {
                    if (data.code == 1) {
                        _this.questionList = data.data.items.filter(ques => ques.imageId) || data.data;
                        if (_this.questionList.length == 0) {
                            _this.$Message.warning('该工程下没有满足要求的虚拟机');
                        }
                    } else {
                        _this.$Message.warning(data.message);
                    }
                })
            },
            queryTargetList() {
                let params = {
                    page: 1,
                    rows: 2147483647,
                };
                queryTargetList(params).then(data => {
                    if (data.code == 1) {
                        this.targetList = data.attribute.data;
                    } else {
                        this.$Message.warning(data.message);
                    }
                })
            },
            changeVm(id) {
                this.formValidate.path = '';
                this.getVmIp(id);
            },
            getVmIp(id) {
                if (id) {
                    let server = this.vmlists.filter(vm => vm.id == id)[0];
                    this.getFlagServerList(server.address[0].ipv4);
                    //this.getFlagServerList(server.addresses[0].ip);
                }
            },
            getFlagServerList(ip) {
                let curIp = ip && ip.split('.').slice(0, 3).join('.');
                let params = {
                    page: 1,
                    pageSize: 1000,
                    projectId: this.$route.query.prjid,
                    ip: curIp
                }
                getFlagServerList(params).then(data => {
                    this.flagServerList = []
                    if (data.code == 1) {
                        //this.pathList = data.data.list;
                        if (data.data.list.length > 0) {
                            this.flagServerList = data.data.list
                            this.formValidate.path = data.data.list[0].addresses[0].applyFlagUrl;
                        }
                        // console.log(this.flagServerList,'flagServerListflagServerList');
                        // if(this.isDistributed==1){
                        //     this.flagServerList=this.flagServerList.filter(item=>{
                        //         return item.rangeId==this.rangeId
                        //     })
                        //     console.log(this.flagServerList,'this.flagServerListthis.flagServerList');
                        // }
                    }
                })
            },
            changeAccess(access) {
//	    	if(access == "1" && this.targetModal.type == 2){
//	    		this.formValidate.externalPort = this.oldFormValidate.externalPort;
//    			this.formValidate.externalIp = this.oldFormValidate.externalIp;
//	    	}else if(access == "2" && this.targetModal.type == 2){
//	    		this.formValidate.port = this.oldFormValidate.port;
//	    	}
            },
//	    getProjectSubnet(){
//	    	queryNetworkList(this.$route.query.prjid,this.projectInfo.network.id).then(data => {
//	    		if(data.code == 1){
//	    			let subnetList = [];
//	    			data.attribute.editorStage.childs.forEach(item => {
//	    				subnetList = subnetList.concat(item.childs);
//	    			})
//	    			this.subnetList = subnetList;
//	    		}
//	    	})
//	    }
            typeFilter(val) {
                let str = '';
                switch (val) {
                    case '0':
                        str = '固定Flag';
                        break;
                    case '1':
                        str = '静态Flag';
                        break;
                    case '2':
                        str = 'Checker';
                        break;
                    case '3':
                        str = '提交报告';
                        break;
                    default:
                        str = '未定义类型';
                        break;
                }
                return str;
            },
        }
    }
</script>

<style>
    .drillsTable .ivu-poptip-body {
        text-align: left !important;
    }

    .scenesHeader {
        margin-bottom: 16px;
    }

    .drillTables {
        min-height: 300px;
    }

    .drillsTable.ivu-table-wrapper {
        overflow: inherit;
    }
</style>
<style scoped>
    ._dot{
        display: inline-block;
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: #f90;
        margin-right: 5px
    }
    .targetHeader {
        /*padding: 10px;*/
        margin: 15px 0;
    }
</style>
